/**
 * SpringBoot_HelloWorld/ender.springBootStudy.springBoot_helloWorld.entity/Persion.java
 */
package ender.springBootStudy.springBoot_helloWorld.entity;

import java.util.Collection;
import java.util.List;

import javax.validation.constraints.NotNull;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;

import com.alibaba.fastjson.JSONObject;

/**
 * @author chenxiwen
 * @date 2017年8月1日下午6:08:34
 */
@Component  //把类交给Spring管理
@ConfigurationProperties(prefix="persion")  //在配置文件中利用persion前缀注入类的属性
//@Validated  //配合校验使用
public class Persion {
    @Value("${defaultName:persion}") //同时有@Value和persion.name时  @Value的值会被覆盖，最后结果为persion.name
    private String name;
    @NotNull(message="性别不能为空")  //可以使用JSR-303 javax.validate 进行数据校验   具体用时再找都有哪些annotation以及用法
    private String gender;
    private int age;
    private String email;
    private List<String> girls;
    private Collection<Integer> numbers;
    
    private Persion[] members;

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the gender
     */
    public String getGender() {
        return gender;
    }

    /**
     * @param gender the gender to set
     */
    public void setGender(String gender) {
        this.gender = gender;
    }

    /**
     * @return the age
     */
    public int getAge() {
        return age;
    }

    /**
     * @param age the age to set
     */
    public void setAge(int age) {
        this.age = age;
    }
    
    /**
     * @return the email
     */
    public String getEmail() {
        return email;
    }

    /**
     * @param email the email to set
     */
    public void setEmail(String email) {
        this.email = email;
    }

    /**
     * @return the girls
     */
    public List<String> getGirls() {
        return girls;
    }

    /**
     * @param girls the girls to set
     */
    public void setGirls(List<String> girls) {
        this.girls = girls;
    }

    /**
     * @return the numbers
     */
    public Collection<Integer> getNumbers() {
        return numbers;
    }

    /**
     * @param numbers the numbers to set
     */
    public void setNumbers(Collection<Integer> numbers) {
        this.numbers = numbers;
    }

    /**
     * @return the members
     */
    public Persion[] getMembers() {
        return members;
    }

    /**
     * @param members the members to set
     */
    public void setMembers(Persion[] members) {
        this.members = members;
    }

    @Override
    public String toString(){
        return JSONObject.toJSONString(this);
    }

    /**
     * 
     */
    public Persion() {
        // TODO Auto-generated constructor stub
    }

}
